package com.zlict.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zlict.common.annotation.Log;
import com.zlict.common.core.controller.BaseController;
import com.zlict.common.core.domain.AjaxResult;
import com.zlict.common.enums.BusinessType;
import com.zlict.admin.domain.RdAssetsAmortizationDetail;
import com.zlict.admin.service.IRdAssetsAmortizationDetailService;
import com.zlict.common.utils.poi.ExcelUtil;
import com.zlict.common.core.page.TableDataInfo;

/**
 * 资产管理-无形资产摊销明细Controller
 * 
 * @author lqh
 * @date 2025-07-05
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/admin/amortizationDetail")
public class RdAssetsAmortizationDetailController extends BaseController
{
    private final IRdAssetsAmortizationDetailService rdAssetsAmortizationDetailService;

    /**
     * 查询资产管理-无形资产摊销明细列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(RdAssetsAmortizationDetail rdAssetsAmortizationDetail)
    {
        startPage();
        List<RdAssetsAmortizationDetail> list = rdAssetsAmortizationDetailService.selectRdAssetsAmortizationDetailList(rdAssetsAmortizationDetail);
        return getDataTable(list);
    }

    /**
     * 导出资产管理-无形资产摊销明细列表
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:export')")
    @Log(title = "资产管理-无形资产摊销明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RdAssetsAmortizationDetail rdAssetsAmortizationDetail)
    {
        List<RdAssetsAmortizationDetail> list = rdAssetsAmortizationDetailService.selectRdAssetsAmortizationDetailList(rdAssetsAmortizationDetail);
        ExcelUtil<RdAssetsAmortizationDetail> util = new ExcelUtil<RdAssetsAmortizationDetail>(RdAssetsAmortizationDetail.class);
        util.exportExcel(response, list, "资产管理-无形资产摊销明细数据");
    }

    /**
     * 获取资产管理-无形资产摊销明细详细信息
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(rdAssetsAmortizationDetailService.selectRdAssetsAmortizationDetailById(id));
    }

    /**
     * 新增资产管理-无形资产摊销明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:add')")
    @Log(title = "资产管理-无形资产摊销明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RdAssetsAmortizationDetail rdAssetsAmortizationDetail)
    {
        return toAjax(rdAssetsAmortizationDetailService.insertRdAssetsAmortizationDetail(rdAssetsAmortizationDetail));
    }

    /**
     * 修改资产管理-无形资产摊销明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:edit')")
    @Log(title = "资产管理-无形资产摊销明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RdAssetsAmortizationDetail rdAssetsAmortizationDetail)
    {
        return toAjax(rdAssetsAmortizationDetailService.updateRdAssetsAmortizationDetail(rdAssetsAmortizationDetail));
    }

    /**
     * 删除资产管理-无形资产摊销明细
     */
//    @PreAuthorize("@ss.hasPermi('admin:amortizationDetail:remove')")
    @Log(title = "资产管理-无形资产摊销明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(rdAssetsAmortizationDetailService.deleteRdAssetsAmortizationDetailByIds(ids));
    }
}
